﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class PrimeGenerator
    {

        bool[] prime;
        public PrimeGenerator()
        {
            int testCase = Int32.Parse(Console.ReadLine());
            prime = new bool[100001];
            while (testCase-- > 0)
            {
                string[] input = Console.ReadLine().Split(' ');
                int a = Int32.Parse(input[0]);
                int b = Int32.Parse(input[1]);

                if(a == 1)
                { a = 2; }

                MakePrime(a, b);
                for (int i = a; i <= b; i++)
                {
                    if (!prime[i - a])
                    {
                        Console.WriteLine(i);
                    }
                }
                Console.WriteLine("");
            }
        }
        private void MakePrime(int a, int b)
        {
            bool[] usePrime = new bool[100000];
            long lb = (long)b;
            int rootB = (int)Math.Sqrt(lb);

            for (int i = 2; i <= rootB; i++)
            {
                int startNum = a / i * i;
                if (startNum < 2)
                { startNum = i; }
                if (startNum - a >= 0)
                {
                    prime[startNum - a] = true;
                }
                for (int j = 2; j < b; j += i)
                {
                    prime[startNum + j - a] = true;
                }
            }
        }
    }
}
